package io.plus.common.packet.metadata;

import io.plus.server.Status;
import io.plus.server.utils.JsonKit;
import lombok.Data;

@Data
public class ResponseMessage {
    private Command command;//响应cmd命令码;
    private int code;//响应状态码;
    private String description = "";//响应状态信息提示;
    private Object data;//响应数据;


    public ResponseMessage() {
    }

    public ResponseMessage(Command command) {
        this.command = command;
    }


    public ResponseMessage(Command command, Status status) {
        this(command);
        this.code = status.getCode();
        this.description = status.getDescription();
    }

    public ResponseMessage(Command command, Status status, Object data) {
        this(command, status);
        this.data = data;
    }

    public ResponseMessage setCommand(Command command) {
        this.command = command;
        return this;
    }

    public ResponseMessage setCode(Integer code) {
        this.code = code;
        return this;
    }

    public ResponseMessage setDescription(String description) {
        this.description = description;
        return this;
    }

    public ResponseMessage setData(Object data) {
        this.data = data;
        return this;
    }


    public byte[] toByte() {
        return JsonKit.toJSONBytesEnumNoUsingName(this);
    }


}
